package com.bit.demo.springioc.component;

import com.bit.demo.springioc.model.Student;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;
//@ComponentScan 扫描指定包下的所有组件
@ComponentScan("com.bit.demo.springioc")
@Component
public class StudentComponent {
    @Bean({"s1","s3"})
//    @Bean(name = {"s4","s5"})
//    @Bean(value = {"s6","s7"})
    public Student s1(){
        return new Student("张三", 18);
    }
    @Bean
    public String s2Name(){
        return "李四";
    }

    @Bean
    public String s3Name(){
        return "李明";
    }
//    @Primary
    @Bean
    public Student s2(@Qualifier("s2Name") String name){
        return new Student(name, 20);
    }
}
